//
//  TabBarCellView.m
//  07-HomeWork
//
//  Created by dllo on 16/7/23.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "TabBarCellView.h"
#define kScreenBounds  [UIScreen mainScreen].bounds
#define kScreenWidth   [UIScreen mainScreen].bounds.size.width
#define kScreenHeight  [UIScreen mainScreen].bounds.size.height
@interface TabBarCellView ()
@property (nonatomic, strong)UIButton *button;
@property (nonatomic, strong)UILabel *label;
@end
@implementation TabBarCellView

- (instancetype)initWithFrame:(CGRect)frame backGroundImage:(UIImage *)image title:(NSString *)title {
    self = [super initWithFrame:frame];
    if (self) {
        [self createButton:frame backGroundImage:image];
        [self createLabel:title];
           }
    return self;
}
- (void)tabBarAddTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents {
    [_button addTarget:target action:action forControlEvents:controlEvents];
}


- (void)createButton:(CGRect)frame backGroundImage:(UIImage *)image {
    _button = [UIButton buttonWithType:UIButtonTypeSystem];
    _button.frame = CGRectMake(0, 0, frame.size.width, frame.size.height - 10);
    [_button setImage:image forState:UIControlStateNormal];
    [self addSubview:_button];
}
- (void)createLabel:(NSString *)title {
    _label = [[UILabel alloc] initWithFrame:CGRectMake(0, self.bounds.size.height - 10, self.bounds.size.width, 10)];
    _label.text = title;
    _label.textColor = [UIColor blackColor];
    _label.font = [UIFont systemFontOfSize:10];
    _label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_label];
}
@end
